# coding: utf-8
import sys

from PySide6.QtCore import Qt, QPropertyAnimation, QPoint
from PySide6.QtGui import QColor
from PySide6.QtWidgets import QApplication, QVBoxLayout, QWidget, QFrame

from qfluentwidgets import Slider, HollowHandleStyle
from components import CustomSlider


class Form(QFrame):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ani = QPropertyAnimation(self, b'pos', self)
        self.ani.setDuration(1000)

        self.setStyleSheet("background-color: #333333; border-radius: 10px; padding: 10px;")
        self.setFixedHeight(200)

    def fadeIn(self):
        self.ani.setDirection(QPropertyAnimation.Direction.Forward)
        self.ani.setStartValue(QPoint(self.x(), self.parent().height() + self.height()))
        self.ani.setEndValue(self.pos())

        self.ani.start()

    def fadeOut(self):
        self.ani.setDirection(QPropertyAnimation.Direction.Backward)
        self.ani.setStartValue(self.pos())
        self.ani.setEndValue(QPoint(self.x(), self.parent().height() + self.height()))
        self.ani.start()



class MainWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.frame = Form(self)
        self.frame.hide()

    def resizeEvent(self, event):
        self.frame.resize(self.width() - 20, self.frame.height())
        self.frame.move(10, self.height() - self.frame.height() - 10)
        super().resizeEvent(event)

    def enterEvent(self, event):
        self.frame.fadeIn()

    def leaveEvent(self, event):
        self.frame.fadeOut()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = MainWindow()
    window.setMinimumSize(800, 600)
    window.show()
    sys.exit(app.exec())
